// ColorCaculate.cpp : implementation file
//

#include "stdafx.h"
#include "ColorCaculate.h"
#include "dmCmnFunc.h"
#include "dm_color.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CColorCaculate dialog


CColorCaculate::CColorCaculate(CWnd* pParent /*=NULL*/)
	: CBCGPDialog(CColorCaculate::IDD, pParent)
{
	EnableVisualManagerStyle(TRUE,TRUE);
	//{{AFX_DATA_INIT(CColorCaculate)
	m_nClrbin = 10;
	//}}AFX_DATA_INIT
	m_nStartclr = 1;
	m_nEndclr = 100;
}


void CColorCaculate::DoDataExchange(CDataExchange* pDX)
{
	CBCGPDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CColorCaculate)
	DDX_Control(pDX, IDC_COLOR_END, m_btnEndclr);
	DDX_Control(pDX, IDC_COLOR_START, m_btnStartclr);
	DDX_Text(pDX, IDC_COLOR_BIN, m_nClrbin);
	DDV_MinMaxInt(pDX, m_nClrbin, 1, 10);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CColorCaculate, CBCGPDialog)
	//{{AFX_MSG_MAP(CColorCaculate)
	ON_BN_CLICKED(IDC_COLOR_START, OnColorStart)
	ON_BN_CLICKED(IDC_COLOR_END, OnColorEnd)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CColorCaculate message handlers

void CColorCaculate::OnColorStart() 
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	dmGetColorDialog(m_nStartclr,&m_nStartclr);
	int clr = dmRGBFromDMColor(m_nStartclr);
	m_btnStartclr.SetFaceColor(clr);

	
}

void CColorCaculate::OnColorEnd() 
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	dmGetColorDialog(m_nEndclr,&m_nEndclr);
	int clr = dmRGBFromDMColor(m_nEndclr);
	m_btnEndclr.SetFaceColor(clr);
}

void CColorCaculate::OnOK() 
{

	CBCGPDialog::OnOK();
}

BOOL CColorCaculate::OnInitDialog() 
{
	CBCGPDialog::OnInitDialog();
	
	int clr = dmRGBFromDMColor(m_nStartclr);
	m_btnStartclr.SetFaceColor(clr);
	m_btnStartclr.m_bDontUseWinXPTheme = TRUE;
	clr = dmRGBFromDMColor(m_nEndclr);
	m_btnEndclr.SetFaceColor(clr);
	m_btnEndclr.m_bDontUseWinXPTheme = TRUE;

	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
